#ifndef  __THETAWEEST_H
#define  __THETAWEEST_H
#include "MC_PMSM_Driver.h"
#include "observer.h"

#define  s8   signed char
#define  s16  signed short int
#define	 s32  signed int 
#define	 u8   unsigned char 
#define	 u16  unsigned short int 
#define	 u32  unsigned int 

typedef struct
{
	s32  OutAlpha;
	s32  Integral;
	s32  BEMF_K;
	s32  Angel;
	s32  Angel2;
	s32  Angel3;
}PLL_Components;


typedef struct
{
	s32 Alfa;
	s32 Beta;
	s32 LPF_alfa;
	s32 LPF_beta;
	u8  CalTime;
	s32 We;
	s32 WeAfterFilter;
	s32 DeltaTheta;
	s32 DeltaWe;
	s32 OffsetTheta;
	
	s32 TRdivL_Ki;
	s32 TdivL_Ku;
	s32 Iest_alfa;
	s32 Iest_beta;
	s32 Ierr_alfa;
	s32 Ierr_beta;
	s32 E_alfa;
	s32 E_beta;
	
	
}ThetaEst_Components;

extern ThetaEst_Components  s_ThetaWeEst;
extern PLL_Components  s_PLL_Compt;
extern void f_MotorBef_Cal(ThetaEst_Components *ThetaWeEst, Clarke_Components Curr_alfa_beta, RevPark_Components Volt_alfa_beta);
extern void f_MotorBef_SMO_Cal(ThetaEst_Components *ThetaWeEst, Clarke_Components Curr_alfa_beta, RevPark_Components Volt_alfa_beta);
extern void f_MotorWe_Cal(ThetaEst_Components *ThetaWeEst,u8 CalTime,s32 Angel);
extern void ThetaEst_Init(ThetaEst_Components *ThetaWeEst);
extern void f_ThetaEst_PLL(PLL_Components *s_PLL_Compt, ThetaEst_Components Motorbef);
extern void f_ThetaEst_PLL2(PLL_Components *s_PLL_Compt, S_SMO Motorbef);


#endif

